package com.example.demo.service.impl;


import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.example.demo.config.PageUtils;
import com.example.demo.config.Query;
import com.example.demo.entity.SysRole;
import com.example.demo.mapper.SysRoleMapper;
import com.example.demo.service.ISysRoleService;
import com.github.pagehelper.PageInfo;
import org.springframework.context.annotation.Primary;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;
import java.util.Map;

/**
 * <p>
 * 角色 服务实现类
 * </p>
 *
 * @author xsl
 * @since 2021-12-27
 */
@Service
@Primary
public class SysRoleServiceImpl extends ServiceImpl<SysRoleMapper, SysRole> implements ISysRoleService {

    @Resource
    SysRoleMapper sysRoleMapper;

    @Override
    public PageUtils queryPage(Map<String, Object> params) {
        //String roleName = (String)params.get("roleName");
        //Long createUserId = (Long)params.get("createUserId");


        IPage<SysRole> page = this.page(
                new Query<SysRole>().getPage(params)
                ,new QueryWrapper<SysRole>()
                        //.like(StringUtils.isNotBlank(roleName),"role_name", roleName) //模糊查询
                        //.eq(createUserId != null,"create_user_id", createUserId)     //精确查询

        );

        return new PageUtils(page);
    }

    @Override
    public List<SysRole> listRole() {
        return sysRoleMapper.listRole();
    }

}
